USE [RD_COMMON]
GO

/****** Object:  Index [PK_Star_BusinessUnit]    Script Date: 08/20/2010 15:24:43 ******/
ALTER TABLE [dbo].[Star_BusinessUnit] ADD  CONSTRAINT [PK_Star_BusinessUnit] PRIMARY KEY CLUSTERED 
(
	[BusinessUnitCode] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO


USE [RD_COMMON]
GO

/****** Object:  Index [IX_BusinessUnit_BusinessUnitID]    Script Date: 08/20/2010 15:24:38 ******/
CREATE NONCLUSTERED INDEX [IX_BusinessUnit_BusinessUnitID] ON [dbo].[Star_BusinessUnit] 
(
	[BusinessUnitID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_196]    Script Date: 08/20/2010 15:24:38 ******/
CREATE NONCLUSTERED INDEX [missing_index_196] ON [dbo].[Star_BusinessUnit] 
(
	[BusinessUnitID] ASC
)
INCLUDE ( [BusinessUnitCode],
[BusinessUnit],
[AddressNumber]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_386]    Script Date: 08/20/2010 15:24:38 ******/
CREATE NONCLUSTERED INDEX [missing_index_386] ON [dbo].[Star_BusinessUnit] 
(
	[Category01Code] ASC
)
INCLUDE ( [BusinessUnitID]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_463]    Script Date: 08/20/2010 15:24:38 ******/
CREATE NONCLUSTERED INDEX [missing_index_463] ON [dbo].[Star_BusinessUnit] 
(
	[Type] ASC
)
INCLUDE ( [BusinessUnitID]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO


USE [RD_COMMON]
GO

/****** Object:  Index [PK_Star_Cost]    Script Date: 08/20/2010 15:25:53 ******/
ALTER TABLE [dbo].[Star_Cost] ADD  CONSTRAINT [PK_Star_Cost] PRIMARY KEY CLUSTERED 
(
	[ItemNumber] ASC,
	[BusinessUnitCode] ASC,
	[Location] ASC,
	[LotNumber] ASC,
	[CostMethodCode] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO



USE [RD_COMMON]
GO

/****** Object:  Index [IX_Cost_CostID]    Script Date: 08/20/2010 15:25:34 ******/
CREATE NONCLUSTERED INDEX [IX_Cost_CostID] ON [dbo].[Star_Cost] 
(
	[CostID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_269]    Script Date: 08/20/2010 15:25:34 ******/
CREATE NONCLUSTERED INDEX [missing_index_269] ON [dbo].[Star_Cost] 
(
	[ItemNumber02] ASC,
	[CostMethodCode] ASC
)
INCLUDE ( [BusinessUnitCode],
[UnitCost],
[DateUpdated]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

USE [RD_COMMON]
GO

/****** Object:  Index [PK_DATESPattern]    Script Date: 08/20/2010 15:26:12 ******/
ALTER TABLE [dbo].[Star_Dates] ADD  CONSTRAINT [PK_DATESPattern] PRIMARY KEY CLUSTERED 
(
	[CompanyDateID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

USE [RD_COMMON]
GO

/****** Object:  Index [IX_Dates]    Script Date: 08/20/2010 15:26:23 ******/
CREATE NONCLUSTERED INDEX [IX_Dates] ON [dbo].[Star_Dates] 
(
	[Dates] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_778]    Script Date: 08/20/2010 15:26:23 ******/
CREATE NONCLUSTERED INDEX [missing_index_778] ON [dbo].[Star_Dates] 
(
	[FiscalMonth] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

USE [RD_COMMON]
GO

/****** Object:  Index [PK_Star_Item]    Script Date: 08/20/2010 15:26:49 ******/
ALTER TABLE [dbo].[Star_Item] ADD  CONSTRAINT [PK_Star_Item] PRIMARY KEY CLUSTERED 
(
	[ItemNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

USE [RD_COMMON]
GO

/****** Object:  Index [IX_Item_ItemNumberID]    Script Date: 08/20/2010 15:26:57 ******/
CREATE NONCLUSTERED INDEX [IX_Item_ItemNumberID] ON [dbo].[Star_Item] 
(
	[ItemNumberID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_119]    Script Date: 08/20/2010 15:26:57 ******/
CREATE NONCLUSTERED INDEX [missing_index_119] ON [dbo].[Star_Item] 
(
	[SalesCategory01Code] ASC
)
INCLUDE ( [ItemNumberID],
[SourceID],
[Source],
[ItemNumber],
[ItemNumber02],
[ItemNumber03],
[Description01],
[Description02],
[SalesCategory01],
[SalesCategory02Code],
[SalesCategory02],
[SalesCategory03Code],
[SalesCategory03],
[SalesCategory04Code],
[SalesCategory04],
[SalesCategory05Code],
[SalesCategory05],
[SalesCategory06Code],
[SalesCategory06],
[SalesCategory07Code],
[SalesCategory07],
[SalesCategory08Code],
[SalesCategory08],
[SalesCategory09Code],
[SalesCategory09],
[SalesCategory10Code],
[SalesCategory10],
[PurchasingCategory01Code],
[PurchasingCategory01],
[PurchasingCategory02Code],
[PurchasingCategory02],
[PurchasingCategory03Code],
[PurchasingCategory03],
[PurchasingCategory04Code],
[PurchasingCategory04],
[PurchasingCategory05Code],
[PurchasingCategory05],
[PurchasingCategory06Code],
[PurchasingCategory06],
[PurchasingCategory07Code],
[PurchasingCategory07],
[PurchasingCategory08Code],
[PurchasingCategory08],
[PurchasingCategory09Code],
[PurchasingCategory09],
[PurchasingCategory10Code],
[PurchasingCategory10],
[ProductGroupCode],
[ProductGroup],
[ItemPriceGroupCode],
[ItemPriceGroup],
[StockingTypeCode],
[StockingType],
[InsertIndicator],
[InsertDate],
[ChangeIndicator],
[ChangeDate],
[DeleteIndicator],
[DeleteDate],
[PurgeDate]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_172]    Script Date: 08/20/2010 15:26:57 ******/
CREATE NONCLUSTERED INDEX [missing_index_172] ON [dbo].[Star_Item] 
(
	[SalesCategory03Code] ASC
)
INCLUDE ( [ItemNumberID],
[SourceID],
[ItemNumber],
[ItemNumber02]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_433]    Script Date: 08/20/2010 15:26:57 ******/
CREATE NONCLUSTERED INDEX [missing_index_433] ON [dbo].[Star_Item] 
(
	[Description01] ASC
)
INCLUDE ( [ItemNumberID],
[SourceID],
[ItemNumber02]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

USE [RD_COMMON]
GO

/****** Object:  Index [PK_Star_ItemBranch]    Script Date: 08/20/2010 15:27:10 ******/
ALTER TABLE [dbo].[Star_ItemBranch] ADD  CONSTRAINT [PK_Star_ItemBranch] PRIMARY KEY CLUSTERED 
(
	[ItemNumber] ASC,
	[BusinessUnitCode] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

USE [RD_COMMON]
GO

/****** Object:  Index [IX_IB_Addressnumber]    Script Date: 08/20/2010 15:27:18 ******/
CREATE NONCLUSTERED INDEX [IX_IB_Addressnumber] ON [dbo].[Star_ItemBranch] 
(
	[AddressNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [IX_ItemBranch_ItemBranchID]    Script Date: 08/20/2010 15:27:18 ******/
CREATE NONCLUSTERED INDEX [IX_ItemBranch_ItemBranchID] ON [dbo].[Star_ItemBranch] 
(
	[ItemBranchID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_257]    Script Date: 08/20/2010 15:27:18 ******/
CREATE NONCLUSTERED INDEX [missing_index_257] ON [dbo].[Star_ItemBranch] 
(
	[SalesCategory01Code] ASC
)
INCLUDE ( [ItemNumber],
[BusinessUnitCode],
[SafetyStock]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_660]    Script Date: 08/20/2010 15:27:18 ******/
CREATE NONCLUSTERED INDEX [missing_index_660] ON [dbo].[Star_ItemBranch] 
(
	[SourceID] ASC,
	[BusinessUnitCode] ASC
)
INCLUDE ( [ItemNumber],
[AddressNumber]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

USE [RD_COMMON]
GO

/****** Object:  Index [PK_Star_Supplier]    Script Date: 08/20/2010 15:27:37 ******/
ALTER TABLE [dbo].[Star_Supplier] ADD  CONSTRAINT [PK_Star_Supplier] PRIMARY KEY CLUSTERED 
(
	[SupplierNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

USE [RD_COMMON]
GO

/****** Object:  Index [IX_SourceID_ParentNum]    Script Date: 08/20/2010 15:27:47 ******/
CREATE NONCLUSTERED INDEX [IX_SourceID_ParentNum] ON [dbo].[Star_Supplier] 
(
	[SourceID] ASC,
	[ParentNumber] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [IX_Supplier_SupplierNumberID]    Script Date: 08/20/2010 15:27:47 ******/
CREATE NONCLUSTERED INDEX [IX_Supplier_SupplierNumberID] ON [dbo].[Star_Supplier] 
(
	[SupplierNumberID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_422]    Script Date: 08/20/2010 15:27:47 ******/
CREATE NONCLUSTERED INDEX [missing_index_422] ON [dbo].[Star_Supplier] 
(
	[SearchTypeCode] ASC
)
INCLUDE ( [SupplierNumberID],
[SupplierNumber],
[SupplierName],
[PaymentTermsAP],
[PaymentTerms],
[SearchType]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

USE [RD_COMMON]
GO

/****** Object:  Index [PK_Star_UOMConversionFactors]    Script Date: 08/20/2010 15:27:57 ******/
ALTER TABLE [dbo].[Star_UOMConversionFactors] ADD  CONSTRAINT [PK_Star_UOMConversionFactors] PRIMARY KEY CLUSTERED 
(
	[BusinessUnitCode] ASC,
	[ItemNumber] ASC,
	[UnitOfMeasure] ASC,
	[RelatedUnitOfMeasure] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO
USE [RD_COMMON]
GO

/****** Object:  Index [missing_index_303]    Script Date: 08/20/2010 15:28:09 ******/
CREATE NONCLUSTERED INDEX [missing_index_303] ON [dbo].[Star_UOMConversionFactors] 
(
	[RelatedUnitOfMeasure] ASC
)
INCLUDE ( [ItemNumber],
[UnitOfMeasure],
[ConversionFactor]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_6]    Script Date: 08/20/2010 15:28:09 ******/
CREATE NONCLUSTERED INDEX [missing_index_6] ON [dbo].[Star_UOMConversionFactors] 
(
	[ItemNumber] ASC,
	[UnitOfMeasure] ASC,
	[RelatedUnitOfMeasure] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

USE [RD_COMMON]
GO
USE [RD_COMMON]
GO
/****** Object:  Index [IX_AR_Star_BillToNumber]    Script Date: 06/16/2009 09:59:20 ******/
CREATE NONCLUSTERED INDEX [IX_AR_Star_BillToNumber] ON [dbo].[AR_Star_Customer] 
(
	[BillToNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO
/****** Object:  Index [IX_AR_Star_Customer_BillTo_Company]    Script Date: 06/16/2009 09:59:20 ******/
CREATE NONCLUSTERED INDEX [IX_AR_Star_Customer_BillTo_Company] ON [dbo].[AR_Star_Customer] 
(
	[BillToNumber] ASC,
	[CompanyNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_AR_Star_Customer_CustomerNumberID]    Script Date: 06/16/2009 09:59:20 ******/
CREATE NONCLUSTERED INDEX [IX_AR_Star_Customer_CustomerNumberID] ON [dbo].[AR_Star_Customer] 
(
	[CustomerNumberID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_AR_Star_CustomerNumber]    Script Date: 06/16/2009 09:59:20 ******/
CREATE NONCLUSTERED INDEX [IX_AR_Star_CustomerNumber] ON [dbo].[AR_Star_Customer] 
(
	[CustomerNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO
/****** Object:  Index [IX_AR_Star_ParentNumber]    Script Date: 06/16/2009 09:59:20 ******/
CREATE NONCLUSTERED INDEX [IX_AR_Star_ParentNumber] ON [dbo].[AR_Star_Customer] 
(
	[ParentNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]

/****** Object:  Index [PK_Star_Account]    Script Date: 08/20/2010 15:23:49 ******/
ALTER TABLE [dbo].[Star_Account] ADD  CONSTRAINT [PK_Star_Account] PRIMARY KEY CLUSTERED 
(
	[AID] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO


USE [RD_COMMON]
GO

/****** Object:  Index [IX_Account_AIDID]    Script Date: 08/20/2010 15:23:44 ******/
CREATE NONCLUSTERED INDEX [IX_Account_AIDID] ON [dbo].[Star_Account] 
(
	[AIDID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [IX_Account_BU]    Script Date: 08/20/2010 15:23:44 ******/
CREATE NONCLUSTERED INDEX [IX_Account_BU] ON [dbo].[Star_Account] 
(
	[Account] ASC,
	[BusinessUnitCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_204]    Script Date: 08/20/2010 15:23:44 ******/
CREATE NONCLUSTERED INDEX [missing_index_204] ON [dbo].[Star_Account] 
(
	[Category12Code] ASC
)
INCLUDE ( [AIDID]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_264]    Script Date: 08/20/2010 15:23:44 ******/
CREATE NONCLUSTERED INDEX [missing_index_264] ON [dbo].[Star_Account] 
(
	[Category17Code] ASC
)
INCLUDE ( [Category17],
[Category17Desc2]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_44]    Script Date: 08/20/2010 15:23:44 ******/
CREATE NONCLUSTERED INDEX [missing_index_44] ON [dbo].[Star_Account] 
(
	[Category13Code] ASC
)
INCLUDE ( [AIDID],
[Category13],
[Category14Code],
[Category14]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_53]    Script Date: 08/20/2010 15:23:44 ******/
CREATE NONCLUSTERED INDEX [missing_index_53] ON [dbo].[Star_Account] 
(
	[Category13Code] ASC
)
INCLUDE ( [AIDID],
[Account],
[AccountDesc],
[Category13],
[Category14Code],
[Category14]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_66]    Script Date: 08/20/2010 15:23:44 ******/
CREATE NONCLUSTERED INDEX [missing_index_66] ON [dbo].[Star_Account] 
(
	[Category13Code] ASC
)
INCLUDE ( [AIDID]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_89]    Script Date: 08/20/2010 15:23:44 ******/
CREATE NONCLUSTERED INDEX [missing_index_89] ON [dbo].[Star_Account] 
(
	[Category13Code] ASC
)
INCLUDE ( [AIDID],
[Account],
[AccountDesc],
[AccountLevelOfDetail],
[Category13],
[Category14Code],
[Category14]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO


USE [RD_COMMON]
GO

/****** Object:  Index [PK_Sales_Star_Customer]    Script Date: 08/20/2010 15:22:58 ******/
ALTER TABLE [dbo].[Sales_Star_Customer] ADD  CONSTRAINT [PK_Sales_Star_Customer] PRIMARY KEY CLUSTERED 
(
	[CustomerNumberID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO



USE [RD_COMMON]
GO

/****** Object:  Index [IX_Sales_Star_CompanyNumber]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [IX_Sales_Star_CompanyNumber] ON [dbo].[Sales_Star_Customer] 
(
	[CompanyNumber] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [IX_Sales_Star_Customer_CustomerNumberID]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [IX_Sales_Star_Customer_CustomerNumberID] ON [dbo].[Sales_Star_Customer] 
(
	[CustomerNumberID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [IX_Sales_Star_Customer_ShipToNumber]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [IX_Sales_Star_Customer_ShipToNumber] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [IX_Sales_Star_InvoiceToNumber]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [IX_Sales_Star_InvoiceToNumber] ON [dbo].[Sales_Star_Customer] 
(
	[InvoicetoNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [IX_Sales_Star_ParentNumber]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [IX_Sales_Star_ParentNumber] ON [dbo].[Sales_Star_Customer] 
(
	[ParentNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [IX_Sales_Star_ShipToNumber]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [IX_Sales_Star_ShipToNumber] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [IX_Sales_Star_SoldToNumber]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [IX_Sales_Star_SoldToNumber] ON [dbo].[Sales_Star_Customer] 
(
	[SoldtoNumber] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_1]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_1] ON [dbo].[Sales_Star_Customer] 
(
	[Category03Code] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoName],
[StopCode]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_101]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_101] ON [dbo].[Sales_Star_Customer] 
(
	[Category06Code] ASC
)
INCLUDE ( [SourceID],
[ShiptoNumber],
[Category03Code]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_103]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_103] ON [dbo].[Sales_Star_Customer] 
(
	[Category06Code] ASC
)
INCLUDE ( [Category03Code],
[Category03]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_105]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_105] ON [dbo].[Sales_Star_Customer] 
(
	[Category06Code] ASC
)
INCLUDE ( [SourceID],
[ShiptoNumber],
[Category05Code]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_107]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_107] ON [dbo].[Sales_Star_Customer] 
(
	[Category06Code] ASC
)
INCLUDE ( [Category05Code],
[Category05]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_109]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_109] ON [dbo].[Sales_Star_Customer] 
(
	[Category06Code] ASC
)
INCLUDE ( [SourceID],
[ShiptoNumber],
[Category04Code]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_111]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_111] ON [dbo].[Sales_Star_Customer] 
(
	[Category06Code] ASC
)
INCLUDE ( [Category04Code],
[Category04]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_115]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_115] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoNumber] ASC,
	[StopCode] ASC
)
INCLUDE ( [ShiptoName]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_117]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_117] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoNumber] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_121]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_121] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoSearchTypeCode] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoName],
[DateOfFirstInvoice]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_123]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_123] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoSearchType] ASC
)
INCLUDE ( [SoldtoNumber],
[ShiptoNumber],
[ShiptoSearchTypeCode]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_125]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_125] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoSearchTypeCode] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoName],
[LastInvoiceDate]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_128]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_128] ON [dbo].[Sales_Star_Customer] 
(
	[Category03Code] ASC
)
INCLUDE ( [SourceID],
[ShiptoNumber],
[ShiptoName],
[StopCode]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_144]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_144] ON [dbo].[Sales_Star_Customer] 
(
	[Category03Code] ASC
)
INCLUDE ( [SourceID],
[ShiptoNumber],
[StopCode]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_1465]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_1465] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoSearchTypeCode] ASC
)
INCLUDE ( [ParentNumber],
[ParentName],
[ShiptoNumber],
[ShiptoName],
[ShiptoAddressLine01],
[ShiptoPostalCode],
[ShiptoCity],
[ShiptoStateCode],
[ShiptoState],
[Category03Code],
[Category03],
[Category04Code],
[Category04],
[Category05Code],
[Category05],
[Category06Code],
[Category06],
[Category08Code],
[Category08],
[Category21Code],
[Category21],
[Category25Code],
[Category25],
[Category27Code],
[Category27],
[Category28Code],
[Category28]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_147]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_147] ON [dbo].[Sales_Star_Customer] 
(
	[Category08Code] ASC
)
INCLUDE ( [CustomerNumberID],
[SourceID],
[ShiptoNumber],
[Category08]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_1473]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_1473] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoSearchTypeCode] ASC,
	[Category06Code] ASC
)
INCLUDE ( [ParentNumber],
[ParentName],
[ShiptoNumber],
[ShiptoName],
[ShiptoAddressLine01],
[ShiptoPostalCode],
[ShiptoCity],
[ShiptoStateCode],
[ShiptoState],
[Category03Code],
[Category03],
[Category04Code],
[Category04],
[Category05Code],
[Category05],
[Category06],
[Category08Code],
[Category08],
[Category21Code],
[Category21],
[Category25Code],
[Category25],
[Category27Code],
[Category27],
[Category28Code],
[Category28]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_152]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_152] ON [dbo].[Sales_Star_Customer] 
(
	[StopCode] ASC,
	[Category03Code] ASC
)
INCLUDE ( [SourceID],
[ShiptoNumber],
[ShiptoName]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_170]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_170] ON [dbo].[Sales_Star_Customer] 
(
	[StopCode] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoName]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_177]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_177] ON [dbo].[Sales_Star_Customer] 
(
	[Category04Code] ASC,
	[Category05Code] ASC,
	[Category06Code] ASC
)
INCLUDE ( [CustomerNumberID],
[SourceID],
[ShiptoNumber],
[Category03Code],
[Category03]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_179]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_179] ON [dbo].[Sales_Star_Customer] 
(
	[Category05Code] ASC
)
INCLUDE ( [Category04Code],
[Category04]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_180]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_180] ON [dbo].[Sales_Star_Customer] 
(
	[Category04Code] ASC,
	[Category05Code] ASC,
	[Category06Code] ASC
)
INCLUDE ( [CustomerNumberID],
[SourceID],
[ShiptoNumber],
[Category04]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_19]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_19] ON [dbo].[Sales_Star_Customer] 
(
	[Category03Code] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoName],
[LastInvoiceDate]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_202]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_202] ON [dbo].[Sales_Star_Customer] 
(
	[Category04Code] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoSearchTypeCode],
[HOLDORDERSCODEDescription],
[DateOfFirstInvoice],
[LastInvoiceDate]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_204]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_204] ON [dbo].[Sales_Star_Customer] 
(
	[Category04Code] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoSearchTypeCode],
[StopCode],
[DateOfFirstInvoice],
[LastInvoiceDate]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_206]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_206] ON [dbo].[Sales_Star_Customer] 
(
	[Category04Code] ASC,
	[ShiptoSearchTypeCode] ASC
)
INCLUDE ( [SourceID],
[ShiptoNumber],
[ShiptoName],
[StopCode],
[Category03Code]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_208]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_208] ON [dbo].[Sales_Star_Customer] 
(
	[Category03Code] ASC
)
INCLUDE ( [Category03]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_212]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_212] ON [dbo].[Sales_Star_Customer] 
(
	[Category09Code] ASC,
	[ShiptoSearchTypeCode] ASC
)
INCLUDE ( [ParentNumber],
[ParentName],
[ShiptoNumber],
[ShiptoName],
[ShiptoAddressLine01],
[ShiptoPostalCode],
[ShiptoCity],
[ShiptoStateCode],
[ShiptoState],
[StopCode],
[Category03Code],
[Category03],
[Category04Code],
[Category04],
[Category05Code],
[Category05],
[Category06Code],
[Category06],
[Category08Code],
[Category08],
[Category21Code],
[Category21],
[Category25Code],
[Category25],
[Category27Code],
[Category27],
[Category28Code],
[Category28]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_214]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_214] ON [dbo].[Sales_Star_Customer] 
(
	[Category04Code] ASC,
	[ShiptoSearchTypeCode] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoName],
[Category03Code],
[LastInvoiceDate]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_216]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_216] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoSearchTypeCode] ASC,
	[Category03Code] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoName],
[LastInvoiceDate]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_225]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_225] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoSearchTypeCode] ASC,
	[Category03Code] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoName],
[ShiptoAddressLine01],
[ShiptoPostalCode],
[ShiptoCity],
[ShiptoStateCode],
[ShiptoState],
[ShiptoSearchType],
[StopCode],
[Category03]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_242]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_242] ON [dbo].[Sales_Star_Customer] 
(
	[Category04Code] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoSearchTypeCode],
[DateOfFirstInvoice],
[LastInvoiceDate]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_272]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_272] ON [dbo].[Sales_Star_Customer] 
(
	[Category04Code] ASC
)
INCLUDE ( [SourceID],
[ShiptoNumber],
[ShiptoName],
[StopCode],
[Category03Code]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_276]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_276] ON [dbo].[Sales_Star_Customer] 
(
	[StopCode] ASC
)
INCLUDE ( [SourceID],
[ShiptoNumber]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_357]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_357] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoSearchTypeCode] ASC
)
INCLUDE ( [ParentNumber],
[ParentName],
[ShiptoNumber],
[ShiptoName],
[ShiptoAddressLine01],
[ShiptoPostalCode],
[ShiptoCity],
[ShiptoStateCode],
[ShiptoState],
[ShiptoSearchType],
[Category03Code],
[Category03],
[Category04Code],
[Category04],
[Category05Code],
[Category05],
[Category06Code],
[Category06],
[Category08Code],
[Category08],
[Category25Code],
[Category25]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_6]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_6] ON [dbo].[Sales_Star_Customer] 
(
	[Category03Code] ASC
)
INCLUDE ( [SoldtoNumber],
[SoldtoName],
[StopCode]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_648]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_648] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoSearchTypeCode] ASC
)
INCLUDE ( [InvoicetoNumber],
[InvoicetoName],
[SoldtoNumber],
[SoldtoName],
[ShiptoNumber],
[ShiptoName]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_652]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_652] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoSearchTypeCode] ASC
)
INCLUDE ( [CustomerNumberID],
[SourceID],
[ShiptoNumber],
[ShiptoName]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_653]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_653] ON [dbo].[Sales_Star_Customer] 
(
	[Category04Code] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoName],
[Category03Code],
[LastInvoiceDate]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_7]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_7] ON [dbo].[Sales_Star_Customer] 
(
	[Category08Code] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoName],
[DateOfFirstInvoice]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_8]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_8] ON [dbo].[Sales_Star_Customer] 
(
	[Category03Code] ASC
)
INCLUDE ( [StopCode]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_83]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_83] ON [dbo].[Sales_Star_Customer] 
(
	[Category06Code] ASC
)
INCLUDE ( [ShiptoNumber],
[ShiptoName],
[StopCode]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_87]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_87] ON [dbo].[Sales_Star_Customer] 
(
	[Category06Code] ASC
)
INCLUDE ( [CustomerNumberID],
[SourceID],
[ShiptoNumber],
[Category06]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO

/****** Object:  Index [missing_index_908]    Script Date: 08/20/2010 15:22:51 ******/
CREATE NONCLUSTERED INDEX [missing_index_908] ON [dbo].[Sales_Star_Customer] 
(
	[ShiptoSearchTypeCode] ASC
)
INCLUDE ( [ParentNumber],
[ParentName],
[ShiptoNumber],
[ShiptoName],
[ShiptoAddressLine01],
[ShiptoPostalCode],
[ShiptoCity],
[ShiptoStateCode],
[ShiptoState],
[StopCode],
[Category03Code],
[Category03],
[Category04Code],
[Category04],
[Category05Code],
[Category05],
[Category06Code],
[Category06],
[Category08Code],
[Category08],
[Category21Code],
[Category21],
[Category25Code],
[Category25],
[Category27Code],
[Category27],
[Category28Code],
[Category28]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
GO


use RD_common;
go

INSERT INTO [RD_COMMON].[dbo].[Star_Item]
           ([ItemNumberID]
           ,[SourceID]
           ,[Source]
           ,[ItemNumber]
           ,[ItemNumber02]
           ,[ItemNumber03]
           ,[Description01]
           ,[Description02]
           ,[SalesCategory01Code]
           ,[SalesCategory01]
           ,[SalesCategory02Code]
           ,[SalesCategory02]
           ,[SalesCategory03Code]
           ,[SalesCategory03]
           ,[SalesCategory04Code]
           ,[SalesCategory04]
           ,[SalesCategory05Code]
           ,[SalesCategory05]
           ,[SalesCategory06Code]
           ,[SalesCategory06]
           ,[SalesCategory07Code]
           ,[SalesCategory07]
           ,[SalesCategory08Code]
           ,[SalesCategory08]
           ,[SalesCategory09Code]
           ,[SalesCategory09]
           ,[SalesCategory10Code]
           ,[SalesCategory10]
           ,[PurchasingCategory01Code]
           ,[PurchasingCategory01]
           ,[PurchasingCategory02Code]
           ,[PurchasingCategory02]
           ,[PurchasingCategory03Code]
           ,[PurchasingCategory03]
           ,[PurchasingCategory04Code]
           ,[PurchasingCategory04]
           ,[PurchasingCategory05Code]
           ,[PurchasingCategory05]
           ,[PurchasingCategory06Code]
           ,[PurchasingCategory06]
           ,[PurchasingCategory07Code]
           ,[PurchasingCategory07]
           ,[PurchasingCategory08Code]
           ,[PurchasingCategory08]
           ,[PurchasingCategory09Code]
           ,[PurchasingCategory09]
           ,[PurchasingCategory10Code]
           ,[PurchasingCategory10]
           ,[ProductGroupCode]
           ,[ProductGroup]
           ,[ItemPriceGroupCode]
           ,[ItemPriceGroup]
           ,[StockingTypeCode]
           ,[StockingType]
           ,[InsertIndicator]
           ,[InsertDate]
           ,[ChangeIndicator]
           ,[ChangeDate]
           ,[DeleteIndicator]
           ,[DeleteDate]
           ,[PurgeDate])
     VALUES
           (1
           ,1
           , 'FARMER_CUSTOM'
           ,0
           ,'Advanced Pricing Adj Line'
           , 'Advanced Pricing Adj Line'
           , 'Advanced Pricing Adj Line'
           ,''
           ,''
           ,''
           ,''
           ,''
           ,''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           ,0
           ,0
           ,0
           ,0
           ,0
           ,0
           ,0)
           
/* check for the cross UOM item exists*/
select * from dbo.Star_UOMConversionFactors a
where  a.unitofmeasure = (select relatedunitofmeasure from dbo.Star_UOMConversionFactors b where a.itemnumber = b.itemnumber and a.unitofmeasure= b.relatedunitofmeasure and a.relatedunitofmeasure = b.unitofmeasure) 

/* insert all UOM not cross */
insert into dbo.Star_UOMConversionFactors

select SOURCE,SourceID,BusinessUnitCode,ItemNumber,RelatedUnitOfMeasure as UnitOfMeasure,UnitOfMeasure as RelatedUnitOfMeasure,UnitOfMeasureStructure,
1.00/ConversionFactor as ConversionFactor,1.00/ConvFactorSecondaryToPrimary as ConvFactorSecondaryToPrimary,UserID,ProgramID,WorkStationID,DateUpdated,
TimeOfDay,ExcludefromPO,ExcludefromSO,CodePurchasePriceCode,CodeSalesPriceCode,InsertIndicator,InsertDate,ChangeIndicator,
ChangeDate,DeleteIndicator,DeleteDate,PurgeDate from dbo.Star_UOMConversionFactors where ConversionFactor <>0 and ConvFactorSecondaryToPrimary<>0
and itemnumber not in (36117, 59375, 37415, 38424,38425,38426,44426,45162,43135)

/* items cross UOM exist(exclude 37415 inserted earlier) */
select * from dbo.Star_UOMConversionFactors
where itemnumber in (36117, 59375, 38424,38425,38426,44426,45162,43135)

/* Compare with UOM conversion*/
select * from dbo.Star_UOMConversionFactors
where itemnumber in (36117, 59375,  38424,38425,38426,44426,45162,43135)
and unitofmeasure <> relatedunitofmeasure


/* Insert Partial exclude 37415*/
insert into dbo.Star_UOMConversionFactors
select SOURCE,SourceID,BusinessUnitCode,ItemNumber,RelatedUnitOfMeasure as UnitOfMeasure,UnitOfMeasure as RelatedUnitOfMeasure,UnitOfMeasureStructure,
1.00/ConversionFactor as ConversionFactor,1.00/ConvFactorSecondaryToPrimary as ConvFactorSecondaryToPrimary,UserID,ProgramID,WorkStationID,DateUpdated,
TimeOfDay,ExcludefromPO,ExcludefromSO,CodePurchasePriceCode,CodeSalesPriceCode,InsertIndicator,InsertDate,ChangeIndicator,
ChangeDate,DeleteIndicator,DeleteDate,PurgeDate from dbo.Star_UOMConversionFactors a
 where  not exists (select relatedunitofmeasure from dbo.Star_UOMConversionFactors b where a.itemnumber = b.itemnumber and a.unitofmeasure= b.relatedunitofmeasure and a.relatedunitofmeasure = b.unitofmeasure) 
 and itemnumber in (36117, 59375, 37415, 38424,38425,38426,44426,45162,43135)

